from django.shortcuts import render
from django.shortcuts import HttpResponse
from app1 import models


# Create your views here.

def app1(request):
    # models.Student.objects.create()
    return HttpResponse("app1")


def book(request, ss):
    return HttpResponse("书籍的编号是:{}".format(ss))


def bookstr(request, ss):
    return HttpResponse("bookstr is:{}".format(ss))


def bookpath(request, path):
    return HttpResponse("book path  is:{}".format(path))


def bookre(request, bookname):
    return HttpResponse("bookre path  is:{}".format(bookname))


def book_zh(request, bookname):
    return HttpResponse("中文书籍:{}".format(bookname))


def exam(request, cls):
    name = request.GET.get("name")
    return HttpResponse("班级:{},姓名:{}".format(cls, name))


def bio(request, username):
    return HttpResponse("bio")


def parm(request):
    parm = request.GET.get("parm")
    return HttpResponse("视图参数 is:{}".format(parm))


def page_not_found(request, exception):
    print(exception)
    return HttpResponse("页面没有找到")


def homepage(request):
    # 逻辑
    return render(request, "home.html", context={"title": "django之template"})


def fruit(request):
    # 逻辑
    return render(request, "fruit.html", context={"fruit": ["苹果", "香蕉", "桔子"]})
    # return render(request, "apple.html", context={"fruit": {"name": "苹果", "price": "2.5"}})


def base(request):
    return render(request, "base.html")


def son(request):
    return render(request, "son.html")


def sever_error(request):
    return HttpResponse("你把服务器搞死了")
